<?php
/**
 * 编辑管理页面模板
 */
defined('IN_WZ') or exit('No direct script access allowed');
include $this->template('header', 'core');
?>

<body class="body pxgridsbody">
    <section class="wrapper">
        <!-- page start-->
        <div class="row">
            <div class="col-lg-12">


                <section class="panel">
                    <?php echo $this->menu($GLOBALS['_menuid']); ?>

                    <div class="panel-body" id="panel-bodys">
                        <table class="table table-striped table-advance table-hover">
                            <thead>
                                <tr>
                                    <th class="hidden-phone tablehead">ID</th>
                                    <th class="tablehead">管理员账号</th>
                                    <th class="tablehead">真实姓名</th>
                                    <th class="tablehead" width="300">角色(组名称)</th>
                                    <th class="tablehead">管理权限</th>
                                    <th class="tablehead">最后登录时间</th>
                                    <th class="tablehead">登录历史</th>
                                    <th class="tablehead">是否在位？</th>
                                    <th class="tablehead">管理操作</th>
                                </tr>
                            </thead>
                            <tbody>
                                <?php
                                $nowtime = SYS_TIME;

                                foreach ($result as $r) {
                                    $mr = $this->db->get_one('member', array('uid' => $r['uid']), 'username');
                                    $lr = $this->db->get_one('logintime', array('uid' => $r['uid'], 'status' => 1), '*');
                                    $uid = $r['uid'];
                                    $atworktime = "`uid`='$uid' AND `starttime`<=$nowtime AND `endtime`>=$nowtime";
                                    $atwork_r = $this->db->get_one('atwork', $atworktime, '*');

                                ?>
                                    <tr>

                                        <td><?php echo $r['uid']; ?></td>
                                        <td><?php echo $mr['username']; ?></td>
                                        <td><?php echo $r['truename']; ?></td>
                                        <td><?php
                                            $role = trim($r['role'], ',');
                                            $role = explode(',', $role);
                                            $tmp = array();
                                            foreach ($role as $_r) {
                                                $tmp[] = $roles[$_r]['name'];
                                            }
                                            echo implode(' , ', $tmp);
                                            ?></td>
                                        <td><?php echo $teamleader[$r['teamleader']]; ?></td>
                                        <td><?php echo time_format($lr['logintime']); ?></td>
                                        <td><a href="?m=core&f=power&v=logintime&uid=<?php echo $r['uid']; ?><?php echo $this->su(); ?>" class="btn btn-default btn-xs">查看记录</a>
                                        </td>
                                        <td><?php echo $atwork_r ? '<font color="red">请假中</font>' : '工作中'; ?></td>

                                        <td>
                                            <a href="?m=core&f=power&v=edit&uid=<?php echo $r['uid']; ?><?php echo $this->su(); ?>" class="btn btn-primary btn-xs">修改</a>
                                            <a href="?m=content&f=editor&v=atwork&uid=<?php echo $r['uid']; ?><?php echo $this->su(); ?>" class="btn btn-info btn-xs">请假管理</a>
                                            <a href="?m=content&f=editor&v=editor_stat&uid=<?php echo $r['uid']; ?><?php echo $this->su(); ?>" class="btn btn-primary btn-xs">稿件统计</a>
                                            <a href="?m=core&f=power&v=delete&uid=<?php echo $r['uid']; ?><?php echo $this->su(); ?>" class="btn btn-danger btn-xs">删除</a>
                                        </td>
                                    </tr>
                                <?php
                                }
                                ?>



                            </tbody>
                        </table>
                    </div>
                </section>
            </div>
        </div>

        <!-- page end-->
    </section>
    <script src="<?php echo R; ?>js/bootstrap.min.js"></script>
    <script src="<?php echo R; ?>js/jquery.nicescroll.js" type="text/javascript"></script>
    <script src="<?php echo R; ?>js/pxgrids-scripts.js"></script>
</body>

</html>